<?php


$connect = mysql_connect('localhost', 'tass', '114'); // DB 연결

$db_id=mysql_select_db("tass",$connect);  // DB 선택


//$userID = $_REQUEST['user'];

$sql = "SELECT * FROM communication;";

$rs = mysql_query($sql, $connect);

while($result = mysql_fetch_array($rs)){
  $id = $result[id];
  $text = $result[text];
  $to_time = $result[to_time];
  $to_id = $result[to_id];

$xmlList.="<chat><id>$id</id><text>$text</text><to_time>$to_time</to_time><to_id>$to_id</to_id></chat>";

}
mysql_free_result($rs);

$xmlDoc="<?xml version='1.0' encoding='utf-8'?><root>$xmlList</root>";

 echo    $xmlDoc;

$dom = new DomDocument();
$dom->loadXML($xmlDoc);
$dom->save("chatxml/".$id .".xml");


?>